package cn.duli.xianer.controller;

import cn.duli.xianer.pojo.MyResult;
import cn.duli.xianer.pojo.OrderRefund;
import cn.duli.xianer.service.OrderRefundService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/orderRefund")
public class OrderRefundController {

    @Autowired
    private OrderRefundService orderRefundService;

    /**
     * 新增订单退款
     * @param orderRefund
     * @return
     */
    @PostMapping("/save")
    @RequiresRoles("business")
    public MyResult save(OrderRefund orderRefund) {
        int orId = orderRefundService.save(orderRefund);
        OrderRefund orderRefund1 = orderRefundService.findById(orId);
        return new MyResult(200, "新增订单退款",null,null,orderRefund1,null);
    }

    /**
     * 根据订单id查询订单退款详情
     * @param oId
     * @return
     */
    @GetMapping("/findByOrderId/{oId}")
    @RequiresRoles("business")
    public MyResult findById(@PathVariable("oId") Integer oId){
        OrderRefund orderRefund = orderRefundService.findByOrderId(oId);
        return new MyResult(200, "根据订单id查询订单退款详情",null,null,orderRefund,null);
    }
}
